<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>管理日志</title>
        <link rel="stylesheet" href="css/bootstrap.min.css"/>
        <link rel="stylesheet" href="css/style.css"/>
        <script src="js/jquery-3.4.1.min.js"></script>
        <script src="js/bootstrap.min.js"></script>
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
        <script src="js/script.js" charset="UTF-8"></script>
        <script>
//                function deleteMyJournal(jid) {
//
//                //这里调用jQuery的ajax函数实现发送ajax请求，删除一个学生，并删除表格中对应的行
//                $.ajax({
//                    url: 'djs', //请求发送给url为servlet5_2的Servlet
//                    type: 'GET', //请求发送方式可以用GET或POST等
//                    data: {"jid": $("#jid").val()}, //发送一个请求参数，名为srollno，参数值为传入的rollno变量的值
//                    success: function () { //服务器端返回一个true或false的标记值，用于判断是否删除成功
//                            alert("删除成功");
//                            $("#div_myj").remove(); //删除id为tr学号，如id为tr201720444的tr元素，也就是删除该学生对应的行
//                    },
//                    error: function () { //error属性指定如果请求失败，要调用的函数
//                        alert("删除失败");
//                    }
//                });
//            }
        </script>
        <style>
            #part0{
                background-image: url(images/graywall.jpg);
                width: 100%;
                min-height:600px ;
/*                text-align: center;*/
            }
            #part2{
                background-color: white; 
                border-radius:10px;
            }
        </style>
    <nav class="navbar navbar-default navbar-static-top">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">Brand</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <li><a href="sajoi">广场</a></li>
                    <li><a href="smjoi">我的</a></li>
                    <li><a href="journalIndex3.jsp">发布</a></li>
                </ul>
                <form class="navbar-form navbar-left" action="sjbks">
                    <div class="form-group">
                        <input name="keyword" type="text" class="form-control" placeholder="输入你想查询的日志标题关键词">
                    </div>
                    <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>                   
                </form>
                <p class="navbar-text">Or</p>
                <form class="navbar-form navbar-left" action="sjbis">
                    <div class="form-group">
                        <input name="keyword2" type="text" class="form-control" placeholder="输入你想查询的ID">
                    </div>
                    <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
                </form>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
    </head>
    <body>
        <div class="container" id="part0">
            <br>
        <div class="container table-responsive" id="part2">

            <br>
            <h3>管理日志</h3>
            <hr>

            <table id="dataTable" class="table table-hover text-center" style=" border: 1px solid silver; ">
                <tr>
                    <th>日志编号</th>
                    <th>日志标题</th>
                    <th>发布时间</th>
                    <th>发布者</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${journalList}" var="jon">
                    <div id="div_myj">
                    <tr id="tr${jon.jid}" >
                        <td class="active">${jon.jid}</td>
                        <td>${jon.title}</td>
                        <td class="active">
                            <fmt:formatDate value="${jon.pubtime}" pattern="yyyy-MM-dd HH:mm:ss" />
                        </td>
                        <td>${jon.id}</td>
                        <td class="active">
                        <a class="btn btn-default" href="sods?jid=${jon.jid}">查看详情</a>
                        <a class="btn btn-default" href="javascript:deleteMyJournal(${jon.jid})" role="button"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除</a>
                        </td>
                    </tr>
                    </div>
                </c:forEach>
            </table>

            <div class="text-right">
                <button onclick="javascript:history.go(-1);"  type="button" class="btn  btn-default"><span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>返回</button>                              
                <br>
            </div>
            <br>
            
        </div>
            <br>
        </div>
        

        <div class="container">

            <br>
            <h1 class="text-center text-success">日志列表</h1>
            <br>

            <table id="dataTable" class="table table-hover text-center">
                <tr>
                    <th>日志编号</th>
                    <th>日志标题</th>
                    <th>发布时间</th>
                    <th>发布人</th>
                    <th>操作</th>
                </tr>
                <c:forEach items="${journalList}" var="jon">
               
                    <tr id="tr${jon.jid}">
                        <td>${jon.jid}</td>
                        <td>${jon.title}</td>
                        <td>
                            <fmt:formatDate value="${jon.pubtime}" pattern="yyyy-MM-dd HH:mm:ss" />
                        </td>
                        <td>${jon.id}</td>
                        <td>
                        <a href="sods?jid=${jon.jid}">查看详情</a>
                        
                        <a href="djs?jid=${jon.jid}">删除</a>
<%--  <a href="javascript:deleteJournal('${jon.jid}');">删除</a>--%>
                        </td>
                    </tr>
                </c:forEach>
            </table>

        </div>
    </body>
</html>
